/*
 * @Author: 李石
 * @Date: 2024-05-20 08:55:53
 * @LastEditors: lishi
 * @LastEditTime: 2024-05-22 11:48:35
 * @Description: 
 * Copyright (c) 2024 by ${lishi0105@163.com}, All Rights Reserved. 
 */
#ifndef _STREAM_SERVICE_HPP_
#define _STREAM_SERVICE_HPP_

#include "StreamDto.hpp"
#include "BaseShared.hpp"
#include "SysParams.hpp"
#include <map>
#include <mutex>
#include <thread>
#include "ThreadPool.h"
#include "StreamProxyer.hpp"

class StreamService : public SharedBase<StreamService> {
public:
    StreamService();
    ~StreamService();
    void init();
    StreamReportDto::Ptr insertStream(const StreamAddDto::Ptr, std::string &err);
    bool removeStream(const StreamIDDto::Ptr, std::string &err);
    StreamReportDto::Ptr getStream(const StreamIDDto::Ptr, std::string &err) const;
    StreamListDto::Ptr getStream(std::string &err) const; 
private:
    void initProxyThread();
    SysParams* sys_params;
    mutable std::mutex m_stream_mtx;
    std::shared_ptr<ThreadPool> m_threadPool;
    std::map<std::string, StreamProxyer::Ptr> proxyer_map;
};

#endif // _HTTP_SERVICE_HPP_